//
//  DetailCellModel.m
//  MyBlog
//
//  Created by NCS on 16/12/29.
//  Copyright © 2016年 YSL. All rights reserved.
//

#import "DetailCellModel.h"
#import "CommentCell.h"

@implementation DetailCellModel
- (DetailCellModel *)initWithModel:(DetailCellModel *)model {
    self = model;
    return self;
}

- (DetailCellModel *)initWithData:(NSDictionary *)data {
    self.avatar = [data valueForKey:@"avatar"];
    self.name = [data valueForKey:@"name"];
    self.time = [data valueForKey:@"time"];
    self.device = [data valueForKey:@"device"];
    self.content = [data valueForKey:@"content"];
    self.image = [data valueForKey:@"image"];
    
    if ([[data valueForKey:@"like"] intValue] > 9999) {
        self.likes = [NSString stringWithFormat:@"%dW+", [[data valueForKey:@"like"] intValue] / 10000];
    } else {
        self.likes = [NSString stringWithFormat:@"%d", [[data valueForKey:@"like"] intValue]];
    }
    
    self.cellHeight = [CommentCell getCellHeightByWidth:DScreenWidth Title:self.content font:[UIFont systemFontOfSize:17]];
    
    return self;
}

- (DetailCellModel *)initWithData:(NSDictionary *)data height:(CGFloat)cellHeight {
    self.avatar = [data valueForKey:@"avatar"];
    self.name = [data valueForKey:@"name"];
    self.time = [data valueForKey:@"time"];
    self.device = [data valueForKey:@"device"];
    self.content = [data valueForKey:@"content"];
    self.image = [data valueForKey:@"image"];
    self.likes = [data valueForKey:@"like"];
    
    self.cellHeight = cellHeight;
    
    return self;
}

@end
